package com.cyzy.server.controller.user;

import com.cyzy.common.result.Result;
import com.cyzy.pojo.dto.StarDTO;
import com.cyzy.server.service.StarService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user/card")
@Slf4j
public class StarController {
    @Autowired
    private StarService starService;

    /**
     * 收藏帖子
     */
    @PostMapping("/star")
    public Result collectCard(@RequestBody StarDTO starDTO) {
        log.info("收藏帖子....");

        starService.starCard(starDTO);

        Integer isStar = starDTO.getIsStar();
        if (isStar == 1) {
            return Result.success("收藏成功！");
        }
        else
            return Result.success("取消收藏成功！");
    }

}
